﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once

#include "GcmpSnapInterface.h"
#include "IObject.h"
#include "Vector3d.h"
#include "SnapType.h"
#include "IGraphicsNodeGroup.h"
#include "ContainerUtil.h"

namespace gcmp
{
    class ISnapContext;
    class IGraphicsNodeReference;

    /// \brief 捕捉结果
    ///
    /// 捕捉结果类型包括：点类型、直线类型、圆弧类型和组合类型
    FINAL_INTERFACE class GCMP_SNAP_INTERFACE_EXPORT ISnap : public IObject
    {
        DEFINE_CAST_DERIVED(gcmp::ISnap, gcmp::IObject);

    public:
        /// \brief 析构函数
        virtual ~ISnap() {}

        /// \brief 创建捕捉点
        /// \param[in] snapType 捕捉类型，只能输入点类型，否则创建失败，返回空指针
        /// \param[in] snapContext 捕捉输入信息
        /// \param[in] snappedPoint 捕捉到的点
        /// \param[in] graphicsNodeReferences 与此捕捉相关的GraphicsNodeReference数组，不能传空指针，否则返回空指针
        /// \return 成功返回创建出来的捕捉点，失败返回空指针
        static OwnerPtr<ISnap> CreatePointSnap(SnapType snapType, const ISnapContext &snapContext, const Vector3d &snappedPoint, const std::set<IGraphicsNodeReference*> &graphicsNodeReferences);

        /// \brief 获取捕捉类型
        /// \return 捕捉类型
        virtual SnapType GetSnapType() const = 0;
        
        /// \brief 获取捕捉到的点
        /// \return 捕捉到的点
        virtual Vector3d GetSnappedPoint() const = 0;

        /// \brief 获取与此捕捉相关的GNoderReference
        /// \return 此捕捉相关的GNoderReference的集合
        virtual const std::set<OwnerPtr<IGraphicsNodeReference>, OwnerPtrContainerUtil::LessPredicate<IGraphicsNodeReference>>& GetSnappedGraphicsNodeReferences() const = 0;

        /// \brief 获取此捕捉的图形表达：图标、文字等
        /// \return 此捕捉的图形表达
        virtual OwnerPtr<IGraphicsNodeGroup> GetHighlightGraphics() const = 0;

        /// \brief 获取此捕捉的长字符串提示
        ///
        /// 状态栏显示的捕捉状态
        /// \return 此捕捉的长字符串提示
        virtual std::wstring GetLongPrompt() const = 0;

        /// \brief 获取此捕捉的短字符串提示
        ///
        /// 在位显示捕捉状态
        /// \return 此捕捉的短字符串提示
        virtual std::wstring GetShortPrompt() const = 0;

        /// \brief 克隆捕捉结果
        /// \return 克隆所得捕捉结果的指针
        virtual OwnerPtr<ISnap> Clone() const = 0;

        /// \brief 获取捕捉输入信息
        /// \return 捕捉输入信息
        virtual const ISnapContext* GetSnapContextFR() const = 0;

        /// \brief 判断是否为近程捕捉
        /// \return 是否为近程捕捉
        virtual bool IsLocalSnap() const = 0;

    public:

        /// \brief 获取捕捉输入信息
        /// \return 捕捉输入信息
        GCMP_OBSOLETE_API(2022/02/01,ISnap::GetSnapContextFR()) virtual OwnerPtr<ISnapContext> GetSnapContext() const = 0;
    };
}




